﻿NExt.UI.Base.Right.BindingSourceRightSetter = Ext.extend(NExt.UI.Base.Right.RightSetter, {
    bindingSource: Ext.emptyFn,

    //todo: temporary code
    setBindingSource: function(bindingSource) {
        this.bindingSource = bindingSource;
        if (Ext.isDefined(this.bindingSource.gridPanel)) {
            this.bindingSource.gridPanel.getSelectionModel().on('selectionchange', this.onBindingSourceCurrentChanged, this);
        }
    },

    onBindingSourceCurrentChanged: function(selectionModel) {
        this.fireEvent('needRefresh');
    },

    isEnabled: function(action) {
        var currentModel = this.bindingSource.getCurrentModel();

        if (currentModel)
            return;

        if (NExt.UI.Base.Right.Action.Open === action)
            return false;

        if (NExt.UI.Base.Right.Action.Edit === action)
            return false;

        if (NExt.UI.Base.Right.Action.Delete === action)
            return false;
    }
});